import java.util.*;

/**
 * 测试
 */
public class Demo {

    public static void main(String[] args) {
        long startTime = System.currentTimeMillis();
        final int N = 100000000;
        BitSet bSet = new BitSet(N);//默认值false  质数为false  合数为true；

        for (int i = 2; i <= Math.sqrt(N); i++)
            if (!bSet.get(i))
                for (int j = i * i; j < N; j += i)
                    bSet.set(j);

        long endTime = System.currentTimeMillis();
        System.out.println(endTime - startTime + " ms"); //结果时间毫秒值

        /*for (int i = 2; i < 100; i++)
            if (!bSet.get(i))
                System.out.println(i);*/
    }
}
